package com.example.back.controller;

import com.example.back.dto.req.DrugFrequencyEditReq;
import com.example.back.dto.req.DrugFrequencyListReq;
import com.example.back.dto.req.DrugUsageListReq;
import com.example.back.service.DrugUsageService;
import com.example.common.support.Result;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 用法用量
 */
@RestController
@Api(tags = "用法用量")
@RequestMapping("/DConfig/DrugUsage")
public class DrugUsageController {
    @Resource
    private DrugUsageService drugUsageService;

    @ApiOperation(value = "获取药品用法用量列表", notes = "获取药品用法用量列表")
    @PostMapping(value = "/list")
    public Result<PageInfo<DrugUsageListReq>> list(@RequestBody DrugFrequencyListReq req) {
        return Result.success(drugUsageService.list(req));
    }

    @ApiOperation(value = "修改和添加用法用量", notes = "修改和添加用法用量")
    @PostMapping(value = "/commitSave")
    public Result<Object> commitSave(@RequestBody DrugFrequencyEditReq req) {
        return Result.success(drugUsageService.commitSave(req));
    }

    @ApiOperation(value = "删除用法用量", notes = "删除用法用量")
    @PostMapping(value = "/commitDel")
    public Result<Object> commitDel(@RequestBody DrugFrequencyEditReq req) {
        return Result.success(drugUsageService.commitDel(req));
    }
}
